using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Linq;
using System.Text;
using Firestarter.DB.Schema.BO;
using Firestarter.DB.Schema.Logic;
using FireStarterModeller.BO;
using NUnit.Framework;

namespace Firestarter.DB.Schema.Test.Logic
{
    [TestFixture]
    public class TestDBReverseEng_GetSchema_Access : TestDBReverseEng_GetSchema
    {
        [TestFixtureSetUp]
        public override void SetupFixture()
        {
            base.SetupFixture();
        }

        protected override TestUtilsDB CreateSchemaTestDbUtil()
        {
            return new TestUtilsDB_Access();
        }

        protected override CreateTableSqlBuilder GetSqlBuilderCreateTable(string tableName)
        {
            return new CreateTableSqlBuilder_Access(tableName);
        }

        protected override DBSchemaExtractor GetDbSchemaExtractor(IDbConnection idbConnection)
        {
            return new DBSchemaExtractor_Access(idbConnection);
        }

        protected override void DropTable(DBTable referencedDBTable, IDbConnection connection)
        {
            //                        base.DropTable(referencedDBTable, connection);
        }

        [Test]
        public override void Test_GetSchema_OneTable()
        {
            //---------------Set up test pack-------------------
            DBTable dbTableWithIDAndCol = GetTableInfoWithIDAndCol();
            CreateTableInDatabase(dbTableWithIDAndCol, _connection);
            DbConnection dbConnection = (DbConnection)_connection;
            //            dbConnection.Open();
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            string[] parameters = CreateParameters(null, null, null, "TABLE");
            DataTable tableDataTable = dbConnection.GetSchema("Tables", parameters);
            //---------------Test Result -----------------------
            Assert.IsNotNull(tableDataTable);
            Assert.AreEqual(1, tableDataTable.Rows.Count);
            //---------------Tear Down -------------------------
            dbConnection.Close();
        }

        [Test]
        public override void TestGetColumn_ColumnDetailsCorrect_AutoIncrementing()
        {
            Assert.Ignore("This is very difficult to implement, so we will leave it for now.");
        }
    }
}
